//
//  MBProgressHUD+Factory.m
//  Objective-C
//
//  Created by S_Line on 2018/6/19.
//  Copyright © 2018年 S_Line. All rights reserved.
//

#import "MBProgressHUD+Factory.h"

@implementation MBProgressHUD (Factory)

+ (instancetype)showDarkHUDAddedTo:(UIView *)view animated:(BOOL)animated {
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:animated];
    hud.bezelView.color = [UIColor grayColor];
    
    return hud;
}


+ (instancetype)showToast:(NSString *)toast image:(UIImage *)image {
    MBProgressHUD *hud = [MBProgressHUD showDarkHUDAddedTo:[UIApplication sharedApplication].keyWindow animated:true];
    
    hud.bezelView.color = [[UIColor blackColor] colorWithAlphaComponent:0.8];
    // Set the custom view mode to show any view.
    hud.mode = MBProgressHUDModeCustomView;
    // Set an image view with a checkmark.
    if (image) {
        hud.customView = [[UIImageView alloc] initWithImage:image];
    }
    // Looks a bit nicer if we make it square.
//    hud.square = image ? false : false;
    // Optional label text.
    hud.label.text = toast ?: @"";
    hud.label.numberOfLines = 0;
    hud.label.textColor = [UIColor whiteColor];
    
    [hud hideAnimated:YES afterDelay:3.f];
    
    return hud;
}

@end
